var myChart;
function change0(){  //页面加载调用
    // if (myChart != null && myChart != "" && myChart != undefined) {
    //     myChart.dispose();
    // }
  //   var tem=''; //温度默认值
  //   $.ajax({
  //       type: "POST",
  //       dataType: "json",
  //       url: "/power/strategy/cold",
  //       data:{tem:tem},//温度数据
  //       success: function(result) {
  //           console.log(result);
  //           console.log(result.price);
  //           var priceValue=document.getElementById("getPrice");
  //            priceValue.innerHTML=result.price+"元";
  //           var text=document.getElementById("getHumidity");
  //           var humidity=text.value;
  //           var airLine="3#6";
  //           var humidityLine="7#6";
  //        console.log(result.path);
  //           console.log(typeof result.path);
  //           //复合开始
  //           //处理复合工况
  //           var edge1=result.path;
  //           console.log(edge1);
  //           var resultEdge1=[];
  //           if(humidity>="75"){
  //               resultEdge1.push(airLine);
  //               resultEdge1.push(humidityLine);
  //           }
  //           for(var index1=0;index1<edge1.length;index1++){
  //               var result1=edge1[index1].split("#").reverse().join("#");
  //               var resultLength1=result1.length;
  //               for(var index=3;index<resultLength1+2;index=index+2){
  //                   resultEdge1.push(result1.substring(index-3,index))
  //
  //               }
  //           }
  //           console.log(resultEdge1);
  //           var path='image://img/sun.png';
  //           var path1='image://img/water11.png'
  //           var path2='image://img/humidity1.png';
  //           var option = JSON.parse(JSON.stringify(line_direction_option));//转数组
  //           var dataLength1=option.series[1].data.length;//线数组的长度
  //
  //           for(var i in resultEdge1){
  //
  //               for(var j=0;j<dataLength1;j++){
  //                   //获取所有线的描述名（即路径名）
  //                   var deviceLineName=option.series[1].data[j].desc;
  //                   //湿度影响新风机组 使用path2的图片
  //                   if((deviceLineName=="8#1")&&(deviceLineName==resultEdge1[i])){
  //                       if(option.series[1].data[j].effect.symbol=='none'){
  //                           option.series[1].data[j].effect.symbol=path;//将箭头图片赋值给symbol，实现流动箭头
  //                       }
  //                   }
  //                  else if((deviceLineName=="7#6")&&(deviceLineName==resultEdge1[i])){
  //                       if(option.series[1].data[j].effect.symbol=='none'){
  //                           option.series[1].data[j].effect.symbol=path2;//将箭头图片赋值给symbol，实现流动箭头
  //                       }
  //                   }
  //                   else  if(deviceLineName==resultEdge1[i]){
  //                       if(option.series[1].data[j].effect.symbol=='none'){
  //                           option.series[1].data[j].effect.symbol=path1;//将箭头图片赋值给symbol，实现流动箭头
  //                       }
  //
  //                   }
  //               }
  //           }
  //           myChart = echarts.init(document.getElementById("line_direction_chart"));
  //           myChart.setOption(option);
  //       },
  //   })
  // return false;
    if (myChart != null && myChart != "" && myChart != undefined) {
        myChart.dispose();
    }
    var option = JSON.parse(JSON.stringify(line_direction_option));//转数组

    myChart = echarts.init(document.getElementById("line_direction_chart"));
    myChart.setOption(option);

}


function change(){ //温度-免费冷-地板   目前正在使用的函数
    //myChart如果已经存在则直接销毁。
    if (myChart != null && myChart != "" && myChart != undefined) {
        myChart.dispose();
    }
    var tem=document.getElementById("getTem");
    var temValue=tem.value;
    var temValueNumber=parseInt(temValue);
    var humidityText=document.getElementById("getHumidity");
    var humidity=humidityText.value;
    var humidityValue=parseInt(humidity);
    $.ajax({
        type: "POST",
        dataType: "json",
        url: "/power/strategy/cold",
        data:{tem:temValue,hum:humidityValue},//温度数据
        success: function(result) {
            // var humidityText=document.getElementById("getHumidity");
            // var humidity=humidityText.value;
            // var humidityValue=parseInt(humidity);
            var airLine="3#6";
            var humidityLine="7#6";
            var temLine="8#1";//温度影响免费冷
            var temLine1="8#4";//温度影响地缘热泵B
            console.log(result.path);
            console.log(typeof result.path);
            //复合开始
            //处理复合工况
            var edge1=result.path;
            console.log(edge1);
            var resultEdge1=[];
            // if(temValue>=32){
            //     resultEdge1.push(temLine);
            // }
            //判断温度是否在范围内
            if(temValueNumber<20||temValueNumber>40){
                layer.alert('请输入20-40度之间的温度数据', {

                    icon: 5,

                    title: "提示"

                });
            }
            //判断湿度是否在范围内
            if(humidityValue<30||humidityValue>90){
                layer.alert('请输入30%-90%之间的湿度数据', {

                    icon: 5,

                    title: "提示"

                });
            }
            if((temValueNumber<20||temValueNumber>40)&&(humidityValue<30||humidityValue>90)){
                layer.alert('请输入20-40度之间的温度数据,30%-90%之间的湿度数据', {

                    icon: 5,

                    title: "提示"

                });
            }
            if(humidity>="75"){
                resultEdge1.push(airLine);
                resultEdge1.push(humidityLine);
            }

            for(var index1=0;index1<edge1.length;index1++){
                var result1=edge1[index1].split("#").reverse().join("#");
                var resultLength1=result1.length;
                for(var index=3;index<resultLength1+2;index=index+2){
                    resultEdge1.push(result1.substring(index-3,index))

                }
            }
            console.log(resultEdge1);
            var path='image://img/sun.png';
            var path1='image://img/water11.png'
            var path2='image://img/humidity1.png';
            var option = JSON.parse(JSON.stringify(line_direction_option));//转数组
            var dataLength1=option.series[1].data.length;//线数组的长度

            for(var i in resultEdge1){

                for(var j=0;j<dataLength1;j++){
                    //获取所有线的描述名（即路径名）
                    var deviceLineName=option.series[1].data[j].desc;
                    //湿度影响新风机组或者温度影响地缘B 使用path的图片
                    if(((deviceLineName=="8#1"))&&(deviceLineName==resultEdge1[i])){
                        if(option.series[1].data[j].effect.symbol=='none'){
                            option.series[1].data[j].effect.symbol=path;//将箭头图片赋值给symbol，实现流动箭头
                        }
                    }
                   else if(((deviceLineName=="8#4"))&&(deviceLineName==resultEdge1[i])){
                        if(option.series[1].data[j].effect.symbol=='none'){
                            option.series[1].data[j].effect.symbol=path;//将箭头图片赋值给symbol，实现流动箭头
                        }
                    }
                   else if((deviceLineName=="7#6")&&(deviceLineName==resultEdge1[i])){
                        if(option.series[1].data[j].effect.symbol=='none'){
                            option.series[1].data[j].effect.symbol=path2;//将箭头图片赋值给symbol，实现流动箭头
                        }
                    }
                    else  if(deviceLineName==resultEdge1[i]){
                        if(option.series[1].data[j].effect.symbol=='none'){
                            option.series[1].data[j].effect.symbol=path1;//将箭头图片赋值给symbol，实现流动箭头
                        }

                    }
                }
            }
            tem.value='';
            humidityText.value='';
            myChart = echarts.init(document.getElementById("line_direction_chart"));
            myChart.setOption(option);
        },
    })

    return false;  //防止页面刷新
}

var line_direction_option = {
    backgroundColor: '#041235',
    // 图的标题
    title: {
        text: '能源知识图谱',
        left: '-5',
        top: '10px',
        textStyle: {
            color: '#ffffff',
            fontFamily: '微软雅黑',
            fontWeight: 'lighter',
            fontSize: 18
        }
    },
    // 提示框的配置
    tooltip: {
        trigger: 'item',
        formatter:"{b0}",


    },
    // 工具箱
    toolbox: {
        // 显示工具箱
        show: true,
        feature: {
            mark: {
                show: true
            },
            // 还原
            restore: {
                show: true
            },
            // 保存为图片
            saveAsImage: {
                show: true
            }
        }
    },
    //     legend: [{
    //     // selectedMode: 'single',
    //     data: categories.map(function (a) {
    //     return a.name;
    // })
    // }],

    xAxis: {
        type: 'value',
        boundaryGap: false,
        show: false
    },
    yAxis: {
        type: 'value',
        show: false
    },
    series: [{
        type: 'graph',
        layout: 'none',
        // silent: true,          //不响应鼠标事件
        coordinateSystem: 'cartesian2d',
        symbolSize: 20,
        showEffectOn: 'render',
        zlevel: 2,
        rippleEffect: {
            period: 3, //波纹秒数
            brushType: 'fill', //stroke(涟漪)和fill(扩散)，两种效果
            scale: 10 //波纹范围
        },
        hoverAnimation: true,


        label: {
            normal: {
                show: true
            }
        },

        data: [
            // points
            {
                "name":"温度",
                "value":[20,100],
                symbolSize:[40,100],
                symbol:'image://img/temperature.png',
                selected:true,
                itemStyle: {
                    color: '#c23531',
                }

            },
            {
                "name":"湿度",
                "value":[600,100],
                symbolSize:100,
                selected:true,
                symbol:'image://img/humidity.png',
                itemStyle: {
                    color: '#c23531'
                }
            },
            {
                "name":"地缘热泵B机组",
                "value":[150,250],
                symbolSize:[120,100],
                selected:true,
                symbol:'image://img/hot.png',
                itemStyle: {
                    color: '#2e4553'
                }
            },
            {
                "name":"地埋管",
                "value":[400,300],
                symbolSize:[100,100],
                selected:true,
                symbol:'image://img/pipe.png',
                itemStyle: {
                    color: '#d48265'
                }
            },
            {
                "name":"地板",
                "value":[200,-80],
                symbolSize:[100,80],
                selected:true,
                symbol:'image://img/floor2.png',
                itemStyle: {
                    color: '#60a0a7'
                }
            },
            {
                "name":"免费冷",
                "value":[150,90],
                symbolSize:[70,100],
                selected:true,
                symbol:'image://img/water11.png',
                itemStyle: {
                    color: '#2e4553'
                }
            },
            {
                "name":"水蓄能",
                "value":[300,110],
                symbolSize:100,
                symbol:'image://img/water5.png',
                selected:true,
                itemStyle: {
                    color: '#2e4553'
                }
            },
            {
                "name":"新风机组",
                "value":[500,-80],
                symbolSize:100,
                selected:true,
                symbol:'image://img/air1.png',
                itemStyle: {
                    color: '#60a0a7'
                }
            },
            {
                "name":"地源热泵A机组",
                "value":[470,150],
                symbolSize:[120,100],
                selected:true,
                symbol:'image://img/hot.png',
                itemStyle: {
                    color: '#2e4553'
                }
            },

        ]
    },

        {
            type: 'lines',
            symbol: ['none', 'arrow'],
            symbolSize: 10,
            coordinateSystem: 'cartesian2d',
            label: {
                show: true,
                position: 'middle',
                fontSize:18,

            },
            lineStyle: {
                normal: {
                    color: '#26abf0',

                    width: 3,
                    opacity: 0.5,
                    curveness: 0,

                }
            },
            effect: {
                show: true,
                // smooth: false,
                trailLength: 0,
                symbol: "none", // ‘circle’, ‘rect’, ‘roundRect’, ‘triangle’, ‘diamond’, ‘pin’, ‘arrow’
                // color: '#507577',
                symbolSize: 50,
                // symbol:planePath,
                // symbol:'none'
            },
            data: [
                {"name":"影响","coords":[[39,119],[110,219]],
                    desc:"8#4",//温度-地源热泵B机组
                    effect: {
                        show: false,

                        trailLength: 0,
                        symbolSize: 40,
                        symbol:'none'
                        // symbol:'none'
                        // symbol:'image://img/sun.png'
                    },
                },//温度影响地源热泵B
                // {"name":"影响","coords":[[20,100]],[150,250]]},
                {"name":"影响","coords":[[45,99],[119,90]],
                    desc:"8#1",// 温度-免费冷 8:温度
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: 40,
                        symbol:'none'
                        // symbol:'image://img/sun.png'
                    },
                },//温度影响免费冷
                // {"name":"影响","coords":[[35,119],[129,69]]},//温度影响免费冷
                {"name":"输入","coords":[[376,298],[201,262]],
                    desc:"5#4",//地埋管-地源热泵B机组 0:地埋管，4:地源热泵B机组
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//地埋管输入地源热泵B
                {"name":"输入","coords":[[381,280],[178,105]],
                    desc:"5#1",//地埋管-免费冷  1：免费冷
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//地埋管输入免费冷
                {"name":"输入","coords":[[414,275],[458,197]],
                    desc:"5#3",//地埋管-地源热泵A机组 3：地源热泵A机组
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//地埋管输入地源热泵A
                {"name":"传递","coords":[[160,51],[190,-40]],
                    desc:"1#0", //免费冷-地板
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//免费冷传递地板
                {"name":"传递","coords":[[180,65],[450,-62]],
                    desc:"1#6", //免费冷-新风机组
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//免费冷传递新风1
                {"name":"传递","coords":[[285,75],[215,-40]],
                    desc:"2#0", //水蓄能-地板
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//水蓄能传递地板
                {"name":"传递","coords":[[327,90],[470,-37]],
                    desc:"2#6",  //水蓄能-新风机组
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//水蓄能传递新风
                {"name":"传递","coords":[[443,130],[240,-55]],
                    desc:"3#0", //地源热泵A机组-地板
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/water11.png'
                    },
                },//地源热泵A机组传递地板
                {"name":"传递","coords":[[475,110],[492,-30]],
                    desc:"3#6", //地源热泵A机组-新风机组 6:新风机组
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        // symbol:'image://img/water11.png'
                        symbol:'none'
                    },
                },//地源热泵A机组传递新风
                {"name":"启动","coords":[[585,75],[535,-30]],
                    desc:"7#6",//湿度-新风机组 7:湿度
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [30,50],
                        symbol:'none'
                        // symbol:'image://img/humidity1.png'
                    },
                },//湿度影响新风
                {"name":"传递","coords":[[177,230],[275,135]],
                    desc:"4#2", //地源热泵B机组-水蓄能
                    effect: {
                        show: true,
                        trailLength: 0,
                        symbolSize: [20,40],
                        symbol:'none'
                        // symbol:'image://img/humidity1.png'
                    },
                },//地源热泵B传递水蓄能


            ],

        }


    ],

};
